< previous page page_606 next page >

Page 606
As you can see in Figure 15.5, you now have duplicate COUNTER values in your table. This can lead to data integrity problems if you are using the COUNTER data type as a guaranteed unique value. You should be careful when you use INSERT INTO statements that contain COUNTER data type columns.
warning.gif
The Microsoft Visual Basic documentation for the behavior of INSERT INTO with COUNTER data types states that duplicate counter values are not appended to the destination table. This is not correct. The only time duplicates are not included in the destination tables is when the COUNTER data type column is defined as the primary key.

We should point out here that if you attempt to append records to a table that has a duplicate primary key value, the new record is not appended to the tableand you do not receive an error message! If you edit the SQLVB05.SQV script to renumber the OtherTitles.JobID values to J001 and J002, you see a different set of results when you run the script. Figure 15.6 shows what you get when you attempt to update duplicate primary key rows.
0606-01.jpg
Figure 15.6.
The results of attempting to append
duplicate primary key rows.
The fact that SQL does not append records with a duplicate key can be used as an advantage. You can easily merge two tables that contain overlapping data and get a single result set that does not contain duplicates. Anyone who has worked with mailing lists can find a use for this feature of the INSERT INTO statement.
Now that you know how to insert rows into tables, it's time to learn how you can update existing rows using the UPDATE_SET statement.

 
< previous page page_606 next page >

If you like this book, buy it!